﻿using FineUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZHDJ.Core.Util;
using ZHDJ.Data.Models.JoinParty;
using ZHDJ.JoinParty.BLL;


namespace JoinParty.admin.JoinPromise
{
    public partial class JoinPartyPromise : PageBase
    {
        public string ID
        {
            get
            {
                return GetQueryIntValue("id");
            }
        }
        #region ViewPower

        /// <summary>
        /// 本页面的浏览权限，空字符串表示本页面不受权限控制
        /// </summary>
        public override string ViewPower
        {
            get
            {
                return "";
            }
        }

        #endregion
        #region Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
                LoadData();
            }
        }

        private void BindData()
        {
        }
        private void LoadData(string IsSave = "")
        {
            var op = DB.PartyJoinPromises.Find("PromiseID");
            if (op != null)
            {
                this.ckContent.Text = op.Promise ?? "";
            }
        }



        private void SaveData()
        {
            var op = DB.PartyJoinPromises.Find("PromiseID");
            if (op != null)
            {
                if (!string.IsNullOrEmpty(op.Promise))
                {
                    op.Promise = this.ckContent.Text;
                    op.ModifyBy = this.CurrentUser.LoginID;
                    op.ModifyTime = DateTime.Now;
                    DB.SaveChanges();
                }

            }
            else
            {
                op = new PartyJoinPromise();
                op.Promise = this.ckContent.Text;
                op.CreateBy = this.CurrentUser.LoginID;
                op.CreateTime = DateTime.Now;
                op.ID = "PromiseID";
                DB.PartyJoinPromises.Add(op);
                DB.SaveChanges();
            }
        }
        #endregion

        #region
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SaveData();
            Alert.Show("保存成功");
        }
        #endregion
    }
}